/**
* selsect选择器
*/ 
<template>
  <el-select v-model="value" placeholder="请选择" @change="selectRoleId">
    <el-option
      v-for="item in options"
      :key="item.id"
      :label="item.name"
      :value="item.id">
    </el-option>
  </el-select>
</template>
<script>
  export default {
    //role_id父组件传入
    props:['role_ids'],
    data() {
      return {
        options: [],
        value:this.role_ids,
      }
    },
    created() {
      this.findAllRoles()
    },
    methods: {
      findAllRoles(){
        this.$axios
        .get("/api/rbacManager/findAllRoles/")
         .then((res) => {
          this.loading = false;
          // console.log(res.data.data);
          if (res.data.code == 200) {
            this.options = res.data.data
          }
        })
        .catch(() => {});
      },
      selectRoleId(){
        //用户的id
        this.$emit('changeOption',this.value)
      }
    },
    watch:{
      role_ids:function(newValue,oldValue){
          this.value=newValue
      }
    },
  }
</script>